package com.cuit.xsc.weishare.model;

import org.json.JSONException;
import org.json.JSONObject;

public class User
{
	private String name;
	private String head;
	private String gender; // 性别 m--男，f--女,n--未知
	private String location;
	private String email;
	private boolean isVip;
	private int followersCount; // 粉丝数
	private int friendsCount; // 关注数
	private int statusesCount; // 微博数
	private int favouritesCount; // 收藏数

	public User()
	{

	}

	public User(String json) throws JSONException
	{
		JSONObject jsonObject = new JSONObject(json);
		constructQQJson(jsonObject);
	}

	public User(JSONObject jsonObject)
	{
		constructQQJson(jsonObject);
	}

	private void constructQQJson(JSONObject json)
	{
		try
		{
			name = json.getString("name");
			head = json.getString("head")+"/100";
			String sex = json.getString("sex");
			if ("1".equals(sex))
			{
				gender = "m";
			}
			else if ("2".equals(sex))
			{
				gender = "f";
			}
			else
			{
				gender = "n";
			} 
			location = json.getString("location");
			
			int vip = json.getInt("isvip");
			if (vip == 1)
			{
				isVip = true;
			}
			
			followersCount = json.getInt("fansnum");
			friendsCount = json.getInt("idolnum");
			statusesCount = json.getInt("tweetnum");
			//favouritesCount = json.getInt("");
			
			
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
		
		
		
		
		
		
		

	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getHead()
	{
		return head;
	}

	public void setHead(String head)
	{
		this.head = head;
	}

	public String getGender()
	{
		return gender;
	}

	public void setGender(String gender)
	{
		this.gender = gender;
	}

	public String getLocation()
	{
		return location;
	}

	public void setLocation(String location)
	{
		this.location = location;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public boolean isVip()
	{
		return isVip;
	}

	public void setVip(boolean isVip)
	{
		this.isVip = isVip;
	}

	public int getFollowersCount()
	{
		return followersCount;
	}

	public void setFollowersCount(int followersCount)
	{
		this.followersCount = followersCount;
	}

	public int getFriendsCount()
	{
		return friendsCount;
	}

	public void setFriendsCount(int friendsCount)
	{
		this.friendsCount = friendsCount;
	}

	public int getStatusesCount()
	{
		return statusesCount;
	}

	public void setStatusesCount(int statusesCount)
	{
		this.statusesCount = statusesCount;
	}

	public int getFavouritesCount()
	{
		return favouritesCount;
	}

	public void setFavouritesCount(int favouritesCount)
	{
		this.favouritesCount = favouritesCount;
	}

}
